# day11作业
#
# 1.
# 请写出下列代码的执行结果：﻿
# 例一：
#
# ```python
#
#
# def func1():
#     print(**'in func1' **)
#
#
# def func2():
#     print(**'in func2' **)
#
#
# ret = func1
#
# ret()
#
# ret1 = func2
#
# ret1()
#
# ret2 = ret
#
# ret3 = ret2
#
# ret2()
#
# ret3()
#
# 执行结果：
#
# ```
#
# ​        例二：
#
# ```python
#
#
# def func1():
#     print(**'in func1' **)
#
#
# def func2():
#     print(**'in func2' **)
#
#
# def func3(x, y):
#     x()
#
#     print(**'in func3' **)
#
#     y()
#
#
# print(111)
#
# func3(func2, func1)
#
# print(222)
#
# 执行结果：
#
#
#
# ```
#
# ​    例三（选做题）：
#
# ```python
#

# def func1():
#     print('in func1')  # 2  5
#
#
# def func2(x): # x = func1
#     print('in func2')  # 1  4
#     return x
#
#
# def func3(y):  # y = func2
#     print('in func3')  # 3
#     return y
#
# ret = func2(func1)
# ret()  # func1()
# ret2 = func3(func2)  # func2
# ret3 = ret2(func1)  # func2(func1)
# ret3()  # func1()



# 执行结果：
#
# ```
#
# 2.
# 看代码写结果：
#
# ```python
#
#
# def func(arg):
#     return arg.replace('苍老师', '***')
#
#
# def run():
#     msg = "Alex的女朋友苍老师和大家都是好朋友"
#     result = func(msg)
#     print(result)
#
#
# run()
# ```
#
# ```python
#
#
# def func(arg):
#     return arg.replace('苍老师', '***')
#
#
# def run():
#     msg = "Alex的女朋友苍老师和大家都是好朋友"
#     result = func(msg)
#     print(result)
#
#
# data = run()
# print(data)
# ```
#
# 3.
# 看代码写结果：
#
# ```python
DATA_LIST = []
# 全局变量如果是一个不可变的数据类型，局部作用域不能对其修改。
# 全局变量如果是一个可变的数据类型，局部作用域可以对其修改。
def func(arg):  # arg = '绕不死你'
    return DATA_LIST.insert(0, arg)


data = func('绕不死你')
print(data)
print(DATA_LIST)
# ```
#
# 4.
# 看代码写结果：
#
# ```python
#
#
# def func():
#     print('你好呀')
#     return '好你妹呀'
#
#
# func_list = [func, func, func]
#
# for item in func_list:
#     val = item()
#     print(val)
# ```
#
# 5.
# 看代码写结果：
#
# ```python
#
#
# def func():
#     print('你好呀')
#     return '好你妹呀'
#
#
# func_list = [func, func, func]
#
# for i in range(len(func_list)):
#     val = func_list[i]()
#     print(val)
# ```
#
# 6.
# 看代码写结果：
#
# ```python
#
#
# def func():
#     return '烧饼'
#
#
# def bar():
#     return '豆饼'
#
#
# def base(a1, a2):  # a1 = func  a2 = bar
#     return a1() + a2()
#
#
# result = base(func, bar)
# print(result)



# ```
#
# 7.
# 看代码写结果：
#
# ```python
# for item in range(10):
#     print(item)
#
# print(item)
# ```
#
# 8.
# 看代码写结果：
#
# ```python
#
#
# def func():
#     for item in range(10):
#         pass
#     print(item)
#
#
# func()
# ```
#
# 9.
# 看代码写结果：
#
# ```python
# item = '老男孩'
# def func():
#     item = 'alex'
#     def inner():
#         print(item)
#     for item in range(10):
#         pass
#     inner()
#
# func()
# ```
#
# 10.
# 看代码写结果：
#
# ```python
# l1 = []
#
#
# def func(args):
#     l1.append(args)
#     return l1
#
#
# print(func(1))
# print(func(2))
# print(func(3))
#
# ```
#
# 11.
# 看代码写结果：
#
# ```python
# name = '太白'
#
#
# def func():
#     global name
#     name = '男神'
#
#
# print(name)
# func()
# print(name)
#
# ```
#
# 12.
# 看代码写结果：
#
# ```python
# name = '太白'
#
#
# def func():
#     print(name)
#
#
# func()
# ```
#
# 13.
# 看代码写结果：
#
# ```python
# name = '太白'
#
#
# def func():
#
#     print(name)
#     name = 'alex'
#
# func()
#


# print(n)
# n = 1
# ```
#
# 14.
# 看代码写结果：
#
# ```Python
#
#
# def func():
#     count = 1
#
#     def inner():
#         nonlocal count
#         count += 1
#         print(count)
#
#     print(count)
#     inner()
#     print(count)
#
#
# func()
# ```
#
# 15.
# 看代码写结果：
#
# ```python
#
#
def extendList(val, list=[]):
    list.append(val)
    return list


list1 = extendList(10)
list2 = extendList(123, [])
list3 = extendList('a')

print('list1=%s' % list1)
print('list2=%s' % list2)
print('list3=%s' % list3)
# ```
#
# 16.
# 看代码写结果：
#
# ```python
#
#
# def extendList(val, list=[]):
#     list.append(val)
#     return list
#
#
# print('list1=%s' % extendList(10))
# print('list2=%s' % extendList(123, []))
# print('list3=%s' % extendList('a'))
# ```
#
# 17.
# 用你的理解解释一下什么是可迭代对象，什么是迭代器。
# 18.
# 如何判断该对象是否是可迭代对象或者迭代器？
# 19.
# 写代码：用while循环模拟for内部的循环机制（ ** 面试题 **）。
# 20.
# 写函数，传入n个数，返回字典
# {‘max’:最大值,’min’:最小值}﻿

print(max([1,2,3]))
print(min((1,2,3)))

def func(*args):
    return {'max': max(args),'min': min(args)}

func(22, 33, 55, 77,11, -6)
# ﻿例如: min_max(2, 5, 7, 8, 4)
# 返回: {‘max’:8,’min’:2}(此题用到max(), min()内置函数)
# 21.
# 写函数，传入一个参数n，返回n的阶乘﻿
# ﻿例如: cal(7)
# 计算7 * 6 * 5 * 4 * 3 * 2 * 1
# 22.
# 写函数，返回一个扑克牌列表，里面有52项，每一项是一个元组(**选做题 **)﻿
# ﻿例如：[(‘红心’，2), (‘草花’，2), …(‘黑桃’，‘A’)]
# 23.
# 写代码完成99乘法表.(**选做题，面试题 **)
#
# 1 * 1 = 1
#
# 2 * 1 = 2
# 2 * 2 = 4
#
# 3 * 1 = 3
# 3 * 2 = 6
# 3 * 3 = 9
#
# ......
#
# 9 * 1 = 9
# 9 * 2 = 18
# 9 * 3 = 27
# 9 * 4 = 36
# 9 * 5 = 45
# 9 * 6 = 54
# 9 * 7 = 63
# 9 * 8 = 72
# 9 * 9 = 81